﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenNI;
using System.Windows.Forms;
using Mapenect.Data;
using Mapenect.GesturePatterns;

namespace Mapenect.GestureInterpreter
{
    class SimpleInterpreter : Interpreter
    {
        FmMain gui;
        public SimpleInterpreter(FmMain gui, DataContainer data) : base(data)
        {
            this.GestureDetected +=new GestureEventhandler(AfterGestureDetected);
            this.gui = gui;
        }

        protected override bool checkForGesture()
        {
            FixedQueueList<MyJoint> joint = this.jointData.GetJoint(user.user1, SkeletonJoint.Torso);
            if (joint == null)
                return false;

            float x_Torso = this.jointData.GetJoint(user.user1, SkeletonJoint.Torso).GetLastElement().X; ;
            float x_RHand = this.jointData.GetJoint(user.user1, SkeletonJoint.RightHand).GetLastElement().X;
            float delta = x_RHand - x_Torso;

            delta = Math.Abs(delta);
            gui.WriteToLog("Delta: " + delta.ToString());

            if (delta > 500)
                return true;
            else
                return false;
        }

        private void AfterGestureDetected(Object sender, EventArgs e)
        {
            MessageBox.Show("Gesture von SimpleInterpreter erkannt!");
        }
    }
}
